<template>
	<div>
		<base-layout ref="layout" :showTitle="false" @pageChange="pageChange" :isPage="true" :operateButtonSwitch="false">
			<div slot="main" slot-scope="{ tableHeight }" style="height: 100%;">
				<base-table ref="interfacetable" :border="true" :showIndex="false" :tabLoading.sync="interfaceLoading"
					:tableHeight="tableHeight" :tableData="tableData" :tableColumn="tableColumn" @onCellClick="getCell">
					<template v-slot:enterTime="{ row }">
						<span>{{ row.enterTime | timeHandle }}</span>
					</template>
					<template v-slot:createTime="{ row }">
						<span>{{ row.createTime | timeHandle }}</span>
					</template>
				</base-table>
			</div>
		</base-layout>

		<!-- 数据字典分类弹窗 -->
		<base-dialog :dialogVisible.sync="detailDialog" :closeModal="false" title="查看详情" width="800px" top="10vh">
			<p style="max-height: 55vh;overflow: auto;">{{ msg }}</p>
		</base-dialog>
	</div>
</template>

<script>
import baseQuantityPerson from "@/components/base/baseQuantityPerson"
import baseLayout from "@/components/base/baseLayout"
import baseTable from "@/components/base/baseTable"
import basePage from '@/components/base/basePage'
import baseDialog from "@/components/base/BaseNewDialog"
import configData from "./configData"
import { GetBillList, GetExecuteResult } from '@/api/apis/interfaceLog.js'
export default {
	components: {
		baseQuantityPerson,
		baseLayout,
		baseTable,
		basePage,
		baseDialog
	},
	data() {
		return {
			detailDialog: false,
			interfaceLoading: false,
			tableData: [],
			// 分页数据
			dataModel: {
				limit: 20,
				page: 1,
				Sequence: '',
				SequenceName: ''
			},
			// 表格高度
			// tableHeight: 'calc(100vh - 137px)',
			tableColumn: configData.tableColumn,
			msg: '',
		}
	},
	filters: {
		timeHandle(val) {
			if (!val) {
				return
			}
			let time = val.split("T")[0]
			return time
		},
	},
	mounted() {
		this.getTableData()
	},
	methods: {

		async getTableData() {
			this.interfaceLoading = true
			setTimeout(() => {
				this.interfaceLoading = false
			}, 10000)
			let params = {
				...this.dataModel
			}
			let res = await GetBillList(params)
			if (res.code == 1) {
				this.tableData = res.data[1]
				this.$nextTick(() => {
					this.$refs.layout.setPageTotal(res.data[0])
				})
			}
			this.interfaceLoading = false
		},
		async getResult(id) {
			let params = {
				id: id
			}
			let res = await GetExecuteResult(params)
			if (res.code == 1) {
				this.msg = res.data[0]
				this.detailDialog = true
			}
		},
		pageChange(model) {
			this.dataModel.limit = model.limit
			this.dataModel.page = model.page
			this.getTableData()
		},
		// 单元格点击事件
		getCell(row, label) {
			this.getResult(row.billid)
		},
	}
}
</script>

<style></style>
